package org.splink.library.tween.sprop {
	import org.splink.library.tween.sprop.ISpecialProp;

	import flash.display.DisplayObject;
	import flash.geom.Rectangle;		

	/**
	 * Enables to tween the scrollRect property of a <code>DisplayObject</code>
	 * 
	 * @author Max Kugland
	 */
	public class ScrollRectProp implements ISpecialProp {
		public static const X : String = "x";		public static const Y : String = "y";		public static const WIDTH : String = "width";		public static const HEIGHT : String = "height";
		private var _target : DisplayObject;

		/**
		 * @param target the DisplayObject on which to apply the scrollRect value
		 */
		public function ScrollRectProp(target : DisplayObject) {
			_target = target;
		}

		/**
		 * @inheritDoc
		 */
		public function apply(target : Object, prop : String, start : Number, end : Number, value : Number, percent : Number) : void {
			var sr : Rectangle = _target.scrollRect;
			sr[prop] = value;
			var r : Rectangle = new Rectangle(sr.x, sr.y, sr.width, sr.height);
			_target.scrollRect = r; 
		}

		/**
		 * @inheritDoc
		 */
		public function getValue(prop : String) : Number {
			return _target.scrollRect[prop];
		}
	}
}
